﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace hpm
{
    class clsQuocTich
    {
        string _maQuocTich, _tenQuocTich, _macDinh;

        DAL da = new DAL();
        public DataTable dtbQuocTich = null;
        SqlCommand slqcom;
        SqlDataAdapter sqlDataAdapter = null;

        public string MaQuocTich
        {
            get { return this._maQuocTich; }
            set { this._maQuocTich = value; }
        }

        public string TenQuocTich
        {
            get { return this._tenQuocTich; }
            set { this._tenQuocTich = value; }
        }

        public string MacDinh
        {
            get { return this._macDinh; }
            set { this._macDinh = value; }
        }


        public DataTable getAllQuocTich()
        {
            da.ketnoiServer();
            dtbQuocTich = new DataTable();
            this.slqcom = new SqlCommand();
            this.slqcom.CommandText = "Select MaQuocTich, TenQuocTich from DMQuocTich order by TenQuocTich";
            this.slqcom.Connection = da.con;
            this.slqcom.CommandType = CommandType.Text;
            this.sqlDataAdapter = new SqlDataAdapter(this.slqcom);
            this.sqlDataAdapter.Fill(dtbQuocTich);
            da.da_closeConnect();
            return dtbQuocTich;
        }

        public string getMacDinh()
        {
            da.ketnoiServer();
            this.slqcom = new SqlCommand();
            this.slqcom.CommandText = "Select TenQuocTich from DMQuocTich WHERE MacDinh = 1";
            this.slqcom.Connection = da.con;
            SqlDataReader reader = slqcom.ExecuteReader();
            reader.Read();
            string DefaultText = reader[0].ToString();
            da.da_closeConnect();
            return DefaultText;
        }

    }
}
